<template>
  <div class="check-logistics" v-if="result">
    <Scroll :data="result" class="logistics-scroll">
      <div class="content">
        <panel-order-detail :showBtn="false" :goodsInfo="orderInfo" />
        <div class="step" v-if="result.list.length">
          <div class="row-item" v-for="(item, index) of result.list" :key="index">
            <div class="row">
              <div class="left">
                <div class="time">{{item.time.split(' ')[1]}}</div>
                <div class="date">{{item.time.split(' ')[0]}}</div>
              </div>
              <div class="right">{{item.status}}</div>
            </div>
            <div class="line"></div>
          </div>
        </div>
        <no-result class="no-more" v-if="!result.list.length" :src="require('@/assets/images/1-zwnr.png')" msg="暂无物流更新~" />
      </div>
    </Scroll>
  </div>
</template>
<script>
import PanelOrderDetail from './panel-order-detail'
import { getGoodsExpress } from '@/api/my'
import Scroll from '@/components/scroll/scroll'
import NoResult from '@/components/no-result/no-result'
const ERR_OK = 200
export default {
  components: {
    PanelOrderDetail,
    Scroll,
    NoResult
  },
  data () {
    return {
      orderInfo: null,
      result: null
    }
  },
  created () {
    if (this.$route.query.orderInfo) {
      this.orderInfo = this.$route.query.orderInfo
      this._getGoodsExpress(this.$route.query.orderInfo.express_no)
    }
  },
  methods: {
    _getGoodsExpress (expressNo) {
      getGoodsExpress(expressNo)
        .then(res => {
          if (res.code === ERR_OK) {
            console.log(res)
            this.result = res.data.result
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.no-more /deep/ .no-result {
  top: 6rem;
}
.check-logistics {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: #f7f7f7;
  z-index: 12;
  touch-action: none;
  .logistics-scroll {
    width: 100%;
    height: 100%;
  }
  .content {
    width: 100%;
    padding: 0.42rem 0.36rem;
    box-sizing: border-box;
    .step {
      margin-top: 0.33rem;
      padding: 0.2rem;
      background: #fff;
      .row-item {
        .row {
          display: flex;
          justify-content: space-between;
          align-items: center;
          .left {
            margin-right: 0.35rem;
            .time,
            .date {
              text-align: center;
              font-size: 0.2rem;
              font-family: PingFang SC;
              font-weight: 400;
              color: rgba(0, 4, 0, 1);
              line-height: 0.2rem;
              white-space: nowrap;
            }
            .date {
              color: #777;
              margin-top: 0.15rem;
            }
          }
          .right {
            flex: 1;
            font-size: 0.22rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(68, 68, 68, 1);
            line-height: 0.36rem;
            text-align: left;
          }
        }
        .line {
          width: 1px;
          height: 25px;
          background: #ccc;
          position: relative;
          left: 30px;
        }
        &:last-child {
          .line {
            display: none;
          }
        }
      }
    }
  }
}
</style>
